import * as Utils from '@/utils/index'
const topNav = [
  { id: 1, name: '车辆资产管理' }
  // { id: 2, name: '图表管理' }
  // { id: 4, name: '价格管理' },
  // { id: 5, name: '结算管理' },
  // { id: 6, name: '质量考核' },
  // { id: 8, name: '系统设置' }
  // { id: 7, name: '第一桶油充值' }
]

const permissionRouter = [
  // 运力管理-车辆配置管理 /vendor/carMgt/carType
  { id: 1, code: '/vendor/carMgt', name: '车辆管理', meta: { title: '车辆管理', icon: 'table' }},
  // { id: 1, code: '/vendor/carMgt/makeBrand', name: '制造商与品牌', meta: { title: '制造商与品牌', icon: 'table' }},
  // { id: 1, code: '/vendor/carMgt/audiVehicle', name: '车系车型', meta: { title: '车系车型', icon: 'table' }},
  // { id: 1, code: '/vendor/carMgt/carType', name: '车型配置', meta: { title: '车型配置', icon: 'table' }},
  { id: 1, code: '/vendor/carMgt/carDetail', name: '车辆管理', meta: { title: '车辆管理', icon: 'table' }},

  // // 运力管理-车辆情况监控
  { id: 1, code: '/vendor/monitor', name: '实时监控', meta: { title: '实时监控', icon: 'table' }},
  { id: 1, code: '/vendor/monitor/carSituation', name: '实时监控', meta: { title: '实时监控', icon: 'table' }},
  //
  { id: 1, code: '/vendor/monitor/bigScreenChartsShow', name: '大屏监控', meta: { title: '大屏监控', icon: 'table' }},
  { id: 1, code: '/vendor/monitor/carSituationChartsShow', name: '车况图表', meta: { title: '车况图表', icon: 'table' }},
  { id: 1, code: '/vendor/monitor', name: '统计报表', meta: { title: '统计报表', icon: 'table' }},
  { id: 1, code: '/vendor/monitor/statisticalReport', name: '统计报表', meta: { title: '统计报表', icon: 'table' }},
  // 系统管理-权限管理
  { id: 8, code: '/sysMgt/authorMgt', name: '权限管理', meta: { title: '权限管理', icon: 'table' }},
  { id: 8, code: '/sysMgt/authorMgt/user', name: '用户管理', meta: { title: '用户管理', icon: 'table' }}
  // { id: 8, code: '/sysMgt/authorMgt/role', name: '角色管理', meta: { title: '角色管理', icon: 'table' }},
]
export default {
  getTopNavs: () => {
    return {
      code: 0,
      message: '获取头路由成功-mock',
      data: topNav
    }
  },
  getSideNavs: (req) => {
    console.log('getSideNavs()-req', req)
    const req_params = Utils.urlParse(req.url)
    console.log('getSideNavs()-req_params', req_params)
    const pid = req_params.pid
    const parent = {
      gmtCreate: 1530496768000,
      icon: null,
      id: 1,
      identity: 'PC',
      name: '报表管理',
      orders: 1,
      permissionValue: null,
      pid: 0,
      status: 1,
      type: 1,
      uri: null
    }
    if (parseInt(pid) === 0) {
      return {
        code: 0,
        message: '获取侧边栏数据成功-mock',
        data: {
          children: permissionRouter.map(i => i),
          parent: parent
        }
      }
    }
    let temp = permissionRouter.filter(i => {
      if (i.id === parseInt(pid)) {
        return true
      } else {
        return false
      }
    })
    temp = temp.map(i => {
      return i
    })
    // topNav => item
    // console.log('topNav', topNav, 'pid', pid)
    const cc = topNav.find(item => item.id === parseInt(pid))
    return {
      code: 0,
      message: '获取侧边栏数据成功-mock',
      data: {
        children: temp,
        parent: {
          gmtCreate: 1530496768000,
          icon: null,
          id: 1,
          identity: 'PC',
          name: cc.name || '报表管理',
          orders: 1,
          permissionValue: null,
          pid: cc.id || 0,
          status: 1,
          type: 1,
          uri: null
        }
      }
    }
  }
}
